Skip to content

Replace log-bridge-agent with Swift parent process holder#4

Merged
AnemoFlower merged 4 commits intomainfrom
refactor/remove-java-agent
Apr 6, 2026
Merged

Replace log-bridge-agent with Swift parent process holder#4
AnemoFlower merged 4 commits intomainfrom
refactor/remove-java-agent

Conversation

@AnemoFlower
Copy link
Copy Markdown
Member

No description provided.

@AnemoFlower AnemoFlower marked this pull request as draft April 4, 2026 06:03
@AnemoFlower AnemoFlower marked this pull request as ready for review April 6, 2026 09:42
@AnemoFlower AnemoFlower requested a review from Copilot April 6, 2026 09:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the previous Java log-bridge-agent approach with a Swift “holder” parent process that launches the JVM child, relays stdout/stderr over a Unix domain socket, and reports the JVM exit code back to the launcher.

Changes:

  • Added --holder mode in Runner to spawn a child runner process, capture its output, and forward logs/exit status via UDS.
  • Updated Launcher to pass --holder/--socket-path/--working-directory arguments instead of injecting -javaagent:...log-bridge-agent.jar.
  • Adjusted socket loop behavior to wait for an explicit exit code message (0xFF) before exiting.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
Sources/Runner/main.swift Implements holder mode, UDS connection + log forwarding, and child process lifecycle handling.
Sources/Launcher/main.swift Updates runner invocation arguments and changes socket termination handling to use a transmitted exit code.
Comments suppressed due to low confidence (1)

Sources/Launcher/main.swift:104

  • lastMessages is still being maintained, but the crash-marker check that used it was removed. This is now unused work/state in the hot read loop; either remove it or reintroduce usage if needed.
    var lastMessages: [String] = []
    var exitCode: Int32?
    
    while true {
        var buffer: [UInt8] = .init(repeating: 0, count: 16384)
        let bytesRead = read(clientSocket, &buffer, buffer.count)
        if bytesRead > 0 {
            if buffer[0] <= 1 {
                if let message: String = .init(bytes: buffer[1..<bytesRead], encoding: .utf8) {
                    if lastMessages.count >= 10 {
                        lastMessages.removeFirst()
                    }
                    lastMessages.append(message)
                    let stream: UnsafeMutablePointer<FILE> = buffer[0] == 0 ? stdout : stderr
                    fputs(message, stream)
                    fflush(stream)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AnemoFlower AnemoFlower merged commit ed7c4f0 into main Apr 6, 2026
@AnemoFlower AnemoFlower deleted the refactor/remove-java-agent branch April 6, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants